/**
 * @USER: Administrator
 * @DATE: 2024/9/28 上午8:38
 * @VERSION: 1.0.0
 */
public class LC2644 {
    public static void main(String[] args) {

    }

    public int maxDivScore(int[] nums, int[] divisors) {
        int min = divisors[0];
        for (int divisor : divisors) {
            if (divisor < min) min = divisor;
        }
        int result = min;
        int maxCount = 0;
        for (int divisor : divisors) {
            int count = 0;
            for (int num : nums) {
                if (num%divisor == 0) {
                    count++;
                    if (count > maxCount) {
                        maxCount = count;
                        result = divisor;
                    }else if (count == maxCount) {
                        if (divisor<=result){
                            result = divisor;
                        }
                    }
                }
            }
        }

        return result;
    }

}
